home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / hello_localized / hello2.c < prev    next >
C/C++ Source or Header  |  1995-09-01  |  1KB  |  45 lines

  1. ;/* Source-File: test.c                     Hello_World - LOCALIZED!
  2.  
  3. CatComp hello.cd CFILE hello_strings.h OBJFILE hello_strings.o
  4. CatComp hello.cd hello.ct CATALOG sys:locale/Catalogs/Français/hello.catalog NOOPTIM
  5. Quit
  6. */
  7.  
  8. #define CATCOMP_NUMBERS
  9. #include "hello_strings.h"
  10. #include <libraries/locale.h>
  11. #include <clib/exec_protos.h>
  12. #include <clib/locale_protos.h>
  13. #include <pragmas/exec_pragmas.h>
  14. #include <pragmas/locale_pragmas.h>
  15. #include <string.h>
  16. #include <proto/dos.h>
  17. #include <proto/exec.h>
  18.  
  19. STRPTR    __asm GetString(register __a0 struct LocaleInfo *li, register __d0 LONG stringNum);
  20.  
  21. /* [Main-Program] **********************************************************
  22.  
  23.    This tiny localization example uses >NO< startupcode.. instead it uses 
  24.    the dos Write() function to write the string directly to the console 
  25.    window... so run from the CLI only!
  26.  
  27. */
  28.  
  29. void hello(void)
  30. {
  31. struct Catalog *Catalog;
  32. struct Library *LocaleBase;        // locale library base
  33.  
  34.     struct DosLibrary *DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 0L);
  35.     Catalog=0L;
  36.     if(LocaleBase = OpenLibrary("locale.library",38)) Catalog=OpenCatalogA(NULL,"hello.catalog",NULL);
  37.  
  38.     Write(Output(), GetCatalogStr(Catalog,MSG_HELLO,"Hello World!\n"), strlen(GetCatalogStr(Catalog,MSG_HELLO,"Hello World!\n")));
  39.  
  40.     if(Catalog)    CloseCatalog(Catalog);        /* Close Locale catalog */
  41.     if(LocaleBase)    CloseLibrary(LocaleBase);     /* Close Locale library */
  42.     if(DOSBase)    CloseLibrary((struct Library *)DOSBase); /* Close DOS Library */
  43. }
  44.  
  45.